//
//  SecurityDepositViewController.m
//  MagicZhao
//
//  Created by hy002 on 2017/12/20.
//  Copyright © 2017年 HUAYU. All rights reserved.
//

#import "SecurityDepositViewController.h"
#import "SYPasswordView.h"
#import "AddCarViewController.h"
#import "BankModel.h"
#import "DrawSuccessViewController.h"

static NSString *cellPath = @"SecurityCell";
@interface SecurityDepositViewController ()<UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate,PayPassWordDelegate>
{
    NSString *agreementStr;
    UIButton *agreement;
    BOOL isSelect;
}
@property (nonatomic, strong)UIView *closeView;
@property (nonatomic, assign)NSInteger closeType;
@property (nonatomic, strong)UIView *blackView;
@property (nonatomic, strong)UITableView *tableview;
@property (nonatomic, strong)NSArray *carAry;
@property (nonatomic, strong)NSDictionary *bankDic;
@property (nonatomic, assign)BOOL isHaveCar;
@property (nonatomic, strong)UIImageView *carimgView;
@property (nonatomic, strong)UILabel *carNumLab;
@property (nonatomic, strong)BankModel *bankModel;
@property (nonatomic, assign)BOOL isPay;

@property (nonatomic, strong) UIView *coverView;
@property (nonatomic, strong) UIView *tipView;

@end

@implementation SecurityDepositViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(Successnotice:) name:@"PaySuccess" object:nil];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"PaySuccess" object:nil];
}

- (void)Successnotice:(NSNotification *)center
{
    if (!_isPay)
    {
        _isPay = YES;
        DrawSuccessViewController *vc = [[DrawSuccessViewController alloc] init];
        vc.titStr = @"实名认证";
        vc.tostStr = @"认证内容正在审核中，请耐心等候...";
        [self.navigationController pushViewController:vc animated:YES];
        
    }
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    isSelect = YES;
    [self requestRegistAgreement];
    _closeType = 0;
    _bankDic = @{@"1002":@"gongsh",@"1005":@"nongh",@"1026":@"zhongguoy",@"1003":@"jianha",@"1001":@"zhaos",@"1066":@"youzheng",@"1020":@"jiaot",@"1004":@"puf",@"1006":@"mins",@"1009":@"xingy",@"1010":@"pinganyh",@"1021":@"zhongx",@"1025":@"huax",@"1027":@"guangf",@"1022":@"guangd",@"1032":@"beij",@"1056":@"ningb"};
    [self creatUI];    
    [self requestBankCarList:nil];
}

- (void)creatUI
{
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = BacksColor;
    self.navigationItem.title = @"支付第三方验证费";
    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 5*displaywidth, SCREEN_WIDTH, 50*displaywidth)];
    topView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:topView];
    
    UILabel *Alabel = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 5*displaywidth, 80*displaywidth, 40*displaywidth) Font:14.0 Text:@"第三方验证费" Color:RGB(77, 77, 77)];
    [topView addSubview:Alabel];
    
    UILabel *moneyLab = [ZCControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-175*displaywidth, 5*displaywidth, 150*displaywidth, 40*displaywidth) Font:14.0 Text:[NSString stringWithFormat:@"￥ %@",_priceStr] Color:RGB(238, 103, 94)];
    moneyLab.textAlignment = NSTextAlignmentRight;
    [topView addSubview:moneyLab];
    
    self.closeView = [[UIView alloc] initWithFrame:CGRectMake(0, 60*displaywidth, SCREEN_WIDTH, 140*displaywidth)];
    _closeView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_closeView];
    UILabel *secondTitLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 0, 80*displaywidth, 39*displaywidth) Font:13.0 Text:@"支付方式" Color:RGB(77, 77, 77)];
    [_closeView addSubview:secondTitLab];
    UIView *lineBview = [[UIView alloc] initWithFrame:CGRectMake(0, 39*displaywidth, SCREEN_WIDTH, 1*displaywidth)];
    lineBview.backgroundColor = LinesColor;
    [_closeView addSubview:lineBview];
    NSArray *imgAry = @[@"weixin",@"alipay"];//@"yinhangk"
    NSArray *nameAry = @[@"微信支付",@"支付宝"];//,@"银行卡"
    NSArray *rightImgAry = @[@"waikuang",@"xuankuang-1"];//,@"gs_icon05"
    for (int i = 0; i < imgAry.count; i++)
    {
        UIImageView *imgView = [ZCControl createImageViewWithFrame:CGRectMake(15*displaywidth, 50*displaywidth*i+47.5*displaywidth, 30*displaywidth, 30*displaywidth) ImageName:imgAry[i]];
        imgView.contentMode = UIViewContentModeScaleAspectFit;
        [_closeView addSubview:imgView];
        UILabel *nameLabel = [ZCControl createLabelWithFrame:CGRectMake(80*displaywidth, 50*displaywidth*i+47.5*displaywidth, SCREEN_WIDTH-130*displaywidth, 30*displaywidth) Font:13.0 Text:nameAry[i] Color:RGB(77, 77, 77)];
        [_closeView addSubview:nameLabel];
        UIImageView *imageView = [ZCControl createImageViewWithFrame:CGRectMake(SCREEN_WIDTH-35*displaywidth, 57.5*displaywidth*i+50*displaywidth, 15*displaywidth, 15*displaywidth) ImageName:rightImgAry[i]];
        imageView.contentMode = UIViewContentModeScaleAspectFit;
        imageView.tag = 500 + i;
        [_closeView addSubview:imageView];
        UIButton *btn = [ZCControl createButtonWithFrame:CGRectMake(0, 40*displaywidth+i*50*displaywidth, SCREEN_WIDTH, 50*displaywidth) ImageName:nil Target:self Action:@selector(closeTypeAction:) Title:nil Font:12.0];
        btn.backgroundColor = [UIColor clearColor];
        btn.tag = 100 + i;
        [_closeView addSubview:btn];
        if (i != 2)
        {
            UIView *lineview11 = [[UIView alloc] initWithFrame:CGRectMake(15*displaywidth, 89*displaywidth+i*50*displaywidth, SCREEN_WIDTH-15*displaywidth, 1*displaywidth)];
            lineview11.backgroundColor = LinesColor;
            [_closeView addSubview:lineview11];
        }
        else
        {
            _carNumLab = nameLabel;
            _carimgView = imgView;
        }
    }
    agreement = [ZCControl createButtonWithFrame:CGRectMake(30*displaywidth, 215*displaywidth, SCREEN_WIDTH-60*displaywidth, 20*displaywidth) ImageName:@"gouxuandaik" Target:self Action:@selector(agreementAction) Title:@"《第三方认证服务协议》" Font:12.0];
    [agreement setTitleColor:RGB(255, 111, 25) forState:UIControlStateNormal];
    [self.view addSubview:agreement];
    
    UIButton *soureBtn = [ZCControl createButtonWithFrame:CGRectMake(60*displaywidth , 250*displaywidth, SCREEN_WIDTH-120*displaywidth, 45*displaywidth) ImageName:nil Target:self Action:@selector(payBtnAction) Title:@"支付" Font:15.0];
    [soureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    soureBtn.backgroundColor = ThemeColor;
    [soureBtn.layer setMasksToBounds:YES];
    [soureBtn.layer setCornerRadius:5*displaywidth];
    [self.view addSubview:soureBtn];
    
    self.blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    _blackView.backgroundColor = RGBA(0, 0, 0, 0.5);
    _blackView.hidden = YES;
    [sharedDelegate.window addSubview:_blackView];
    UITapGestureRecognizer *tap11 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ggViewPressed)];
    tap11.delegate = self;
    [_blackView addGestureRecognizer:tap11];
    self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(50*displaywidth, SCREEN_HEIGHT/2-80*displaywidth, SCREEN_WIDTH-100*displaywidth, 100*displaywidth) style:UITableViewStylePlain];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    //    _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableview.backgroundColor = [UIColor whiteColor];
    _tableview.layer.cornerRadius = 10;
    _tableview.layer.masksToBounds = YES;
    if (@available(iOS 11.0, *)) {
        _tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    _tableview.estimatedRowHeight = 0;
    _tableview.estimatedSectionHeaderHeight = 0;
    _tableview.estimatedSectionFooterHeight = 0;
    [_blackView addSubview:_tableview];
    
    
}

//协议
- (void)agreementAction
{
    [self showTipView];
}

- (void)showTipView {
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
    singleTap.cancelsTouchesInView = NO;
    [window addGestureRecognizer:singleTap];
    if (!_coverView) {
        _coverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        _coverView.backgroundColor = [UIColor blackColor];
        _coverView.alpha = 0;
        [window addSubview:_coverView];
    }
    _coverView.hidden = NO;
    
    if (!_tipView) {
        _tipView = [[UIView alloc] initWithFrame:CGRectMake(40, (SCREEN_HEIGHT - 400*displaywidth)/2, SCREEN_WIDTH - 80, 400*displaywidth)];
        _tipView.backgroundColor = [UIColor whiteColor];
        _tipView.alpha = 0;
        _tipView.layer.cornerRadius = 2;
        _tipView.layer.masksToBounds = YES;
        [window addSubview:_tipView];
    }
    _tipView.hidden = NO;
    [UIView transitionWithView:_coverView duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
        _coverView.alpha = 0.4;
        _tipView.alpha = 1;
    } completion:nil];
    UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 16, _tipView.frame.size.width, 30)];
    tipLabel.text = @"《第三方认证服务协议》";
    tipLabel.textAlignment = NSTextAlignmentCenter;
    tipLabel.font = [UIFont systemFontOfSize:18];
    tipLabel.textColor = UIColorHexValue(0x4D4D4D);
    [_tipView addSubview:tipLabel];
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(18, 56, _tipView.frame.size.width - 36, 250*displaywidth)];
    [webView loadHTMLString:agreementStr baseURL:nil];
    webView.backgroundColor = [UIColor whiteColor];
    [_tipView addSubview:webView];
    
    UILabel *lineLabel = [ZCControl createLabelWithFrame:CGRectMake(0, _tipView.frame.size.height - 50, _tipView.frame.size.width, 1) Font:16 Text:nil Color:nil];
    lineLabel.backgroundColor = RGB(233, 234, 233);
    [_tipView addSubview:lineLabel];
    
    UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(25, _tipView.frame.size.height - 40, (_tipView.frame.size.width - 100) / 2, 30)];
    cancelBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [cancelBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
    cancelBtn.layer.cornerRadius = 5;
    cancelBtn.layer.masksToBounds = YES;
    cancelBtn.layer.borderColor = ThemeColor.CGColor;
    cancelBtn.layer.borderWidth = 1;
    cancelBtn.backgroundColor = [UIColor whiteColor];
    [cancelBtn setTitle:@"不同意" forState:UIControlStateNormal];
    [cancelBtn addTarget:self action:@selector(onClickCancelBtn) forControlEvents:UIControlEventTouchUpInside];
    [_tipView addSubview:cancelBtn];
    UIButton *ensureBtn = [[UIButton alloc] initWithFrame:CGRectMake(25*3 + (_tipView.frame.size.width - 100) / 2, _tipView.frame.size.height - 40, (_tipView.frame.size.width - 100) / 2, 30)];
    ensureBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    ensureBtn.backgroundColor = ThemeColor;
    ensureBtn.layer.cornerRadius = 5;
    ensureBtn.layer.masksToBounds = YES;
    [ensureBtn setTitle:@"同意" forState:UIControlStateNormal];
    [ensureBtn addTarget:self action:@selector(onClickEnsureBtn) forControlEvents:UIControlEventTouchUpInside];
    [_tipView addSubview:ensureBtn];
}

- (void)onClickCancelBtn {
    isSelect = NO;
    [agreement setImage:[UIImage imageNamed:@"xuankuang3"] forState:UIControlStateNormal];
    [self hideTipView];
}

- (void)onClickEnsureBtn {
    isSelect = YES;
    [agreement setImage:[UIImage imageNamed:@"gouxuandaik"] forState:UIControlStateNormal];
    [self hideTipView];
}

-(void)keyboardHide:(UITapGestureRecognizer*)tap {
    [self hideTipView];
}

- (void)hideTipView {
    if (_coverView) {
        [UIView transitionWithView:_coverView duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
            _coverView.alpha = 0;
        } completion:nil];
        _coverView.hidden = YES;
    }
    if (_tipView) {
        [UIView transitionWithView:_tipView duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
            _tipView.alpha = 0;
        } completion:nil];
        _tipView.hidden = YES;
    }
}

- (void)requestRegistAgreement {
    WEAKSELF;
    //    [MBProgressHUD showHUDAddedTo:self.view animated:YES];第三方认证服务
    [HYBaseHandler requestGetRegistAgreeMentParmers:@{@"key":@"contractor_identity_pay_agreement"} Success:^(id obj)
     {
         //         [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
         if ([obj server_Getcodecheck])
         {
             NSLog(@"%@", obj);
             agreementStr = obj[@"data"][@"propertyValue"];
         }
         else
         {
             [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
         }
     } failed:^(NSError *error) {
         //         [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
         
     }];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return _carAry.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellPath];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (_carAry.count > 0)
    {
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        BankModel *model = _carAry[indexPath.row];
        NSString *backImg = @"zhongguoy";
        if ([_bankDic.allKeys containsObject:model.bankId])
        {
            backImg = _bankDic[model.bankId];
        }
        UIImageView *imgView = [ZCControl createImageViewWithFrame:CGRectMake(20*displaywidth, 15*displaywidth, 20*displaywidth, 20*displaywidth) ImageName:backImg];
        imgView.contentMode = UIViewContentModeScaleAspectFill;
        [cell.contentView addSubview:imgView];
        NSInteger lenth = model.cardNum.length;
        NSString *carNum = @"0000";
        if (lenth > 4)
        {
            carNum = [model.cardNum substringFromIndex:lenth-4];
        }
        UILabel *namelab = [ZCControl createLabelWithFrame:CGRectMake(45*displaywidth, 10*displaywidth, SCREEN_WIDTH-180*displaywidth, 30*displaywidth) Font:13.0 Text:[NSString stringWithFormat:@"%@ %@ (%@)",model.bank,@"",carNum] Color:RGB(77, 77, 77)];
        [cell.contentView addSubview:namelab];
        
    }
    
    
    return cell;
    
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    BankModel *model = _carAry[indexPath.row];
    if ([_bankDic.allKeys containsObject:model.bankId])
    {
        _carimgView.image = [UIImage imageNamed:_bankDic[model.bankId]];
    }
    if (model.cardNum.length > 4)
    {
        NSString *carLastStr = [model.cardNum substringFromIndex:model.cardNum.length-4];
        _carNumLab.text = [NSString stringWithFormat:@"%@尾号%@储蓄卡",model.bank,carLastStr];
    }
    _bankModel = model;
    _blackView.hidden = YES;
    UIImageView *imageView = (UIImageView *)[_closeView viewWithTag:500];
    imageView.image = [UIImage imageNamed:@"xuankuang-1"];
    UIImageView *imageBView = (UIImageView *)[_closeView viewWithTag:501];
    imageBView.image = [UIImage imageNamed:@"xuankuang-1"];
    _closeType = 2;
    
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-100*displaywidth, 50*displaywidth)];
    myView.backgroundColor = [UIColor whiteColor];
    UIButton *backBtn = [ZCControl createButtonWithFrame:CGRectMake(10*displaywidth, 17.5*displaywidth, 15*displaywidth, 15*displaywidth) ImageName:@"backimg" Target:self Action:@selector(backAction) Title:nil Font:12.0];
    backBtn.backgroundColor = [UIColor clearColor];
    [myView addSubview:backBtn];
    UILabel *titlab = [ZCControl createLabelWithFrame:CGRectMake(35*displaywidth, 10*displaywidth, SCREEN_WIDTH-170*displaywidth, 30*displaywidth) Font:15.0 Text:@"选择银行卡" Color:RGB(77, 77, 77)];
    titlab.textAlignment = NSTextAlignmentCenter;
    [myView addSubview:titlab];
    UIView *lineview = [[UIView alloc] initWithFrame:CGRectMake(0, 49*displaywidth, SCREEN_WIDTH-100*displaywidth, 1*displayheight)];
    lineview.backgroundColor = LinesColor;
    [myView addSubview:lineview];
    return myView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50*displaywidth;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 50*displaywidth;
}


- (void)backAction
{
    _blackView.hidden = YES;
}

- (void)ggViewPressed
{
    _blackView.hidden = YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if ([touch.view isDescendantOfView:_tableview]) {
        return NO;
    }
    return YES;
}



- (void)closeTypeAction:(UIButton *)btn
{
    NSInteger index = btn.tag - 100;
    NSString *aImg = @"";
    NSString *bImg = @"";
    if (index == 0)
    {
         _closeType = index;
        _carimgView.image = [UIImage imageNamed:@"yinhangk"];
        _carNumLab.text = @"银行卡";
        aImg = @"waikuang";
        bImg = @"xuankuang-1";
        
    }
    else if (index == 1)
    {
         _closeType = index;
        _carimgView.image = [UIImage imageNamed:@"yinhangk"];
        _carNumLab.text = @"银行卡";
        bImg = @"waikuang";
        aImg = @"xuankuang-1";
    }
    else
    {
        if (_isHaveCar)
        {
            if (_carAry.count > 0)
            {
                _blackView.hidden = NO;
                [_tableview reloadData];
            }
        }
        else
        {
            AddCarViewController *vc = [[AddCarViewController alloc] init];
            vc.isTixian = YES;
            WEAKSELF;
            vc.addBlock = ^(BankModel *model) {
                weakSelf.bankModel = model;
                weakSelf.closeType = 2;
                UIImageView *imageView = (UIImageView *)[weakSelf.closeView viewWithTag:500];
                imageView.image = [UIImage imageNamed:@"xuankuang-1"];
                UIImageView *imageBView = (UIImageView *)[weakSelf.closeView viewWithTag:501];
                imageBView.image = [UIImage imageNamed:@"xuankuang-1"];
                [weakSelf requestBankCarList:model];
            };
            [self.navigationController pushViewController:vc animated:YES];
        }
    }
    UIImageView *imageView = (UIImageView *)[_closeView viewWithTag:500];
    imageView.image = [UIImage imageNamed:aImg];
    UIImageView *imageBView = (UIImageView *)[_closeView viewWithTag:501];
    imageBView.image = [UIImage imageNamed:bImg];
    
    
}

- (void)payBtnAction
{
    if (!isSelect) {
        [LTools showMBProgressWithText:@"请先勾选协议,才可支付" addToView:self.view];
        return;
    }
    if (_closeType != 2)
    {
        PayManager *manager = [PayManager sharePayManager];
        [manager startPayRequest:_closeType Pid:_orderNo];
    }
   
}


- (void)requestBankCarList:(BankModel *)closeModel
{
    WEAKSELF;
    [HYBaseHandler requestBankCarListParmers:nil Success:^(id obj)
     {
         if ([obj server_Getcodecheck])
         {
             weakSelf.carAry = [BankModel mj_objectArrayWithKeyValuesArray:obj[@"data"]];
             if (weakSelf.carAry.count > 0)
             {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     weakSelf.isHaveCar = YES;
                     if (weakSelf.closeType == 2)
                     {
                         BankModel *model = weakSelf.carAry[0];
                         if (closeModel != nil)
                         {
                             model = closeModel;
                             
                         }
                         if ([_bankDic.allKeys containsObject:model.bankId])
                         {
                             weakSelf.carimgView.image = [UIImage imageNamed:_bankDic[model.bankId]];
                         }
                         if (model.cardNum.length > 4)
                         {
                             NSString *carLastStr = [model.cardNum substringFromIndex:model.cardNum.length-4];
                             weakSelf.carNumLab.text = [NSString stringWithFormat:@"%@尾号%@储蓄卡",model.bank,carLastStr];
                         }
                     }
                     
                     CGFloat h = (weakSelf.carAry.count+1)*50*displaywidth;
                     if (h > 250*displaywidth)
                     {
                         h = 250*displaywidth;
                     }
                     weakSelf.tableview.frame = CGRectMake(50*displaywidth, SCREEN_HEIGHT/2-h/2-30*displaywidth, SCREEN_WIDTH-100*displaywidth, h);
                     [weakSelf.tableview reloadData];
                 });
             }
             else
             {
                 weakSelf.isHaveCar = NO;
             }
             
             
         }
         else
         {
             [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
         }
         
     } failed:^(NSError *error) {
         
     }];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
